package com.example.gokchinesefoodmappcdev.service.impl;

import com.example.gokchinesefoodmappcdev.dao.GoodsAttrKeyDao;
import com.example.gokchinesefoodmappcdev.dao.GoodsInfoDao;
import com.example.gokchinesefoodmappcdev.entity.dto.GoodsDTO;
import com.example.gokchinesefoodmappcdev.service.GoodsAttrKeyService;
import com.example.gokchinesefoodmappcdev.service.GoodsInfoService;
import com.example.gokchinesefoodmappcdev.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GoodsAttrKeyServiceImpl implements GoodsAttrKeyService {

    @Autowired
    GoodsAttrKeyDao goodsAttrKeyDao;

    @Override
    public Integer selectAttrKeyIdByGoodIdAndAttrName(Integer goodId, GoodsDTO goodsInfo) {
        String attrName = goodsInfo.getAttrName();
        Integer attrKeyId = goodsAttrKeyDao.selectAttrKeyIdByGoodIdAndAttrName(goodId, attrName);
        return attrKeyId;
    }

    @Override
    public ResultData insertGoodsAttrKey(Integer goodId, GoodsDTO goodsInfo) {

        String attrName = goodsInfo.getAttrName();
        int i = goodsAttrKeyDao.insertGoodsAttrKey(goodId, attrName);
        if(i>0){
            return new ResultData(0,"操作成功!");
        }

        return new ResultData(500,"操作失败");
    }
}
